import os

txt_folder = r"C:\Users\Desktop\bin"

def process_file(file_path):
    lines_to_keep = []
    
    with open(file_path, 'r', encoding='utf-8') as file:
        for line in file:
            first_column = line.split(' ')[0]
            if first_column in ['9', '10']:
                lines_to_keep.append(line)

    with open(file_path, 'w', encoding='utf-8') as file:
        file.writelines(lines_to_keep)

def process_folder(folder_path):
    for filename in os.listdir(folder_path):
        if filename.endswith(".txt"):
            file_path = os.path.join(folder_path, filename)
            process_file(file_path)
            print(f"Processed: {file_path}")

# 处理文件夹中的所有txt文件
process_folder(txt_folder)
